#include "pro.h"


#define MARK '='
#define SIZE 101


// version2.0
void Flushprocess(double total, double current)
{
    const char* lab = "\|/-";
    static int index = 0;
    int len = strlen(lab);

    char mark[SIZE];
    memset(mark, 0, sizeof(mark));
    double rate = (current*100) / total;
    int num = (int)rate;
    int i = 0;
    for(; i < num; i++)
        mark[i] = MARK;
    

    printf("[%-100s][%.1f%%][%c]\r", mark, rate, lab[index++]);
    fflush(stdout);
    index %= len;

    if(num >= 100) printf("\n");

}


// version1.0
void process()
{
    int rate = 0;
    char mark[SIZE];
    memset(mark, 0, sizeof(mark));
    const char* lab = "\|/-";
    int len = strlen(lab);

    mark[0] = MARK;

    while(rate <= 100)
    {
        printf("[%-100s][%d%%][%c]\r", mark, rate, lab[rate%len]);
        fflush(stdout);
        rate++;
        mark[rate] = MARK;
        usleep(50000);
    }

    printf("\n");
    
}

